package com.ruoyi.web.controller.squad;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.squadweb.domain.SquadjsCustomMessage;
import com.ruoyi.squadweb.service.ISquadjsCustomMessageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 广播自定义消息Controller
 *
 * @author LJY
 * @date 2023-10-28
 */
@RestController
@RequestMapping("/squad/rcon")
public class SquadjsCustomMessageController extends BaseController
{
    @Autowired
    private ISquadjsCustomMessageService squadjsCustomMessageService;

    /**
     * 查询广播自定义消息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:message:list')")
    @GetMapping("/custom/message/list")
    public TableDataInfo list(SquadjsCustomMessage squadjsCustomMessage)
    {
        startPage();
        List<SquadjsCustomMessage> list = squadjsCustomMessageService.selectSquadjsCustomMessageList(squadjsCustomMessage);
        return getDataTable(list);
    }

    /**
     * 导出广播自定义消息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:message:export')")
    @Log(title = "广播自定义消息", businessType = BusinessType.EXPORT)
    @PostMapping("/custom/message/export")
    public void export(HttpServletResponse response, SquadjsCustomMessage squadjsCustomMessage)
    {
        List<SquadjsCustomMessage> list = squadjsCustomMessageService.selectSquadjsCustomMessageList(squadjsCustomMessage);
        ExcelUtil<SquadjsCustomMessage> util = new ExcelUtil<SquadjsCustomMessage>(SquadjsCustomMessage.class);
        util.exportExcel(response, list, "广播自定义消息数据");
    }

    /**
     * 获取广播自定义消息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:message:query')")
    @GetMapping(value = "/custom/message/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(squadjsCustomMessageService.selectSquadjsCustomMessageById(id));
    }

    /**
     * 新增广播自定义消息
     */
//    @PreAuthorize("@ss.hasPermi('system:message:add')")
    @Log(title = "广播自定义消息", businessType = BusinessType.INSERT)
    @PostMapping("/custom/message")
    public AjaxResult add(@RequestBody SquadjsCustomMessage squadjsCustomMessage)
    {
        return toAjax(squadjsCustomMessageService.insertSquadjsCustomMessage(squadjsCustomMessage));
    }

    /**
     * 修改广播自定义消息
     */
//    @PreAuthorize("@ss.hasPermi('system:message:edit')")
    @Log(title = "广播自定义消息", businessType = BusinessType.UPDATE)
    @PutMapping("/custom/message")
    public AjaxResult edit(@RequestBody SquadjsCustomMessage squadjsCustomMessage)
    {
        return toAjax(squadjsCustomMessageService.updateSquadjsCustomMessage(squadjsCustomMessage));
    }

    /**
     * 删除广播自定义消息
     */
//    @PreAuthorize("@ss.hasPermi('system:message:remove')")
    @Log(title = "广播自定义消息", businessType = BusinessType.DELETE)
	@DeleteMapping("/custom/message/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(squadjsCustomMessageService.deleteSquadjsCustomMessageByIds(ids));
    }
}
